<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-新建${name_china}</title>
 <%@include file="/common/head.jsp" %>

 <!-- 上传下载插件 -->
 <link href="<%=request.getContextPath()%>/static/plugin/uploadify/style/uploadify.css" rel="stylesheet">
 <script src="<%=request.getContextPath()%>/static/plugin/uploadify/js/jquery.uploadify.js"></script>

<!-- 时间日期插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/My97DatePicker/skin/default/datepicker.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/My97DatePicker/WdatePicker.js"></script>

<!-- 下拉树插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/zTree/js/jquery.ztree.all-3.5.min.js"></script>

<!--富文本插件 -->
<script src="<%=request.getContextPath()%>/static/plugin/ckeditor/ckeditor.js"></script>


<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/image-server/style/style.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/webuploader.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/uploader.css">
<script type="text/javascript" src="<%=request.getContextPath()%>/static/plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/common.js"></script>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>新建${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="addForm" method="post">
  <div id="left" style="width:80%;float:left">
   
	 <div class="form-wrapper">
	 
		<div class="h4 distance-double">
	        <span class="h4-title"><i class="icon icon-setting"></i>商品信息</span>
	        <span class="h4-border"></span>
	    </div>
	    
	    <input type="hidden" name="categoryId" value="${categoryId}"/>
	    
        <input type="hidden" id="productId" name="productId"/>
	     <div class="form-cont">
	        <p class="form-cont-title">排序号</p>
	        <input type="text" id="reorder" name="reorder" class="summer-input summer-validatebox"  data-validatebox="validType:['noNegativeNumber']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><!-- <span class="field-required">*</span> -->展示主图片</p>
	        <input type="hidden" id="mainImage" name="mainImage"/> 
	        <p style="color:red">建议480*400</p>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><!-- <span class="field-required">*</span> -->轮播图片</p>
	        <input type="hidden" id="images" name="images"/> 
	        <p style="color:red">建议480*400</p>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>商品名称</p>
	        <input type="text" id="name" name="name" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[300]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">简介</p>
	        <textarea class="summer-textarea" id="content" name="content"></textarea>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>视频封面</p>
	        <input type="hidden" id="videoImage" name="videoImage"/> 
	        <p style="color:red">建议480*400</p>
	     </div>
	     
	      <div class="form-cont">
            <p class="form-cont-title"><!-- <span class="field-required">*</span> -->视频</p>
            <!-- 这里一定要写一个id隐藏 -->
            <input type="hidden" id="vedeo" name="vedeo"> 
            <p style="color:red">建议不要太大</p>
         </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><!-- <span class="field-required">*</span> -->形状</p>
	        <input type="text" id="shape" name="shape" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[300]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><!-- <span class="field-required">*</span> -->种地</p>
	        <input type="text" id="area" name="area" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[50]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><!-- <span class="field-required">*</span> -->口径</p>
	        <input type="text" id="koujing" name="koujing" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[50]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>价格</p>
	        <input type="text" id="price" name="price" class="summer-input summer-validatebox"  data-validatebox="validType:['required','positiveInteger']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">规格</p>
	        <textarea class="summer-textarea" id="note" name="note"></textarea>
	     </div>
	     
	     
	     
	     
	 <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="backBtn">关闭</a>
     </div>
  </div>
  </div>
	
</form>
<script>
    var  permission = CommonUtil.getPermission('${name_english}');
    $(function () {
    	
    	
        $("#images").filePlugin({
     		type:"image"
     	});
    	
        $("#videoImage").filePlugin({
     		type:"image"
     	});
    	
    	$("#vedeo").filePlugin({
     		type:"video"
     	});
    	
    	$("#mainImage").filePlugin({
     		type:"image"
     	});
    	
    	//filePlugin("#images","#imagesPicker","#imagesList");
    	//filePlugin("#mainImage","#mainImagePicker","#mainImageList");
    	//filePlugin("#videoImage","#videoImagePicker","#videoImageList");
    	  //初始化附件
	    //initUploadConfig();
     	//初始化下拉选项
   	   $('#shape').combobox({
           valueField : 'code',
           textField : 'name',
           url : COMMON_URL.getCode + '?type=T_XH_PRODUCT_SHAPE'
       });
     	
   	   //初始化下拉选项
   	   $('#area').combobox({
           valueField : 'code',
           textField : 'name',
           url : COMMON_URL.getCode + '?type=T_XH_PRODUCT_AREA'
       });
     	
     	//初始化下拉选项
   	   $('#koujing').combobox({
           valueField : 'code',
           textField : 'name',
           url : COMMON_URL.getCode + '?type=T_XH_PRODUCT_KOUJING'
       }); 
     	
     	
   	
     	$('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:add']
        }));
    	
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:add"]', {isContinue: false},  submit);
    	
    	//返回按钮
    	$('#backBtn,#goBack').on('click',backMain);
    	
    });
    
  
    //表单提交
    function submit(event) {
    	
         $("#addForm").form({
        	 buttons : ['#saveBtn','#saveBtnContinue'],
             ajax: {
                 url: CONST_URL.ADD
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
  	                type:'ok',//显示类型 有info、 ok、 danger
  	                text: '保存成功！',
  	                onBeforeHide: function () {
  	            	  var isContinue = event.data.isContinue;
                   	  if (isContinue) {
                   		  //alert(data.data);
                   		  
                   		  $("#productId").val(data.data);
                   		  //将商品变为不可编辑
                          resetForm();
                   		  
                   	  } else {
                   		  backMain();
                   	  }
  	               }
              	});
              }
         }).form("submit");
    }
    
    
    //保存并继续清空form
    function resetForm(){
        
    }
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_LIST;
    }
    
    //请求url
    var CONST_URL = {
        INIT_LIST: basePath + "${common_url}initList?categoryId=${categoryId}",
    	INIT_MAIN: basePath + "${common_url}init",
       	ADD: basePath + "${common_url}add"
    };
    
</script>
</body>
</html>